package com.group.service.impl.invoice;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.group.service.invoice.InvoiceServiceI;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import com.group.entity.invoice.InvoiceEntity;
import java.util.UUID;
import java.io.Serializable;

@Service("invoiceService")
@Transactional
public class InvoiceServiceImpl extends CommonServiceImpl implements InvoiceServiceI {

	
 	public <T> void delete(T entity) {
 		super.delete(entity);
 		//执行删除操作配置的sql增强
		this.doDelSql((InvoiceEntity)entity);
 	}
 	
 	public <T> Serializable save(T entity) {
 		Serializable t = super.save(entity);
 		//执行新增操作配置的sql增强
 		this.doAddSql((InvoiceEntity)entity);
 		return t;
 	}
 	
 	public <T> void saveOrUpdate(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
 		this.doUpdateSql((InvoiceEntity)entity);
 	}
 	
 	/**
	 * 默认按钮-sql增强-新增操作
	 * @param id
	 * @return
	 */
 	public boolean doAddSql(InvoiceEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-更新操作
	 * @param id
	 * @return
	 */
 	public boolean doUpdateSql(InvoiceEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-删除操作
	 * @param id
	 * @return
	 */
 	public boolean doDelSql(InvoiceEntity t){
	 	return true;
 	}
 	
 	/**
	 * 替换sql中的变量
	 * @param sql
	 * @return
	 */
 	public String replaceVal(String sql,InvoiceEntity t){
 		sql  = sql.replace("#{id}",String.valueOf(t.getId()));
 		sql  = sql.replace("#{serial_number}",String.valueOf(t.getSerialNumber()));
 		sql  = sql.replace("#{invoice_amount}",String.valueOf(t.getInvoiceAmount()));
 		sql  = sql.replace("#{invoice_title}",String.valueOf(t.getInvoiceTitle()));
 		sql  = sql.replace("#{identify_number}",String.valueOf(t.getIdentifyNumber()));
 		sql  = sql.replace("#{receiver_name}",String.valueOf(t.getReceiverName()));
 		sql  = sql.replace("#{receiver_mobile}",String.valueOf(t.getReceiverMobile()));
 		sql  = sql.replace("#{area}",String.valueOf(t.getArea()));
 		sql  = sql.replace("#{detail_address}",String.valueOf(t.getDetailAddress()));
 		sql  = sql.replace("#{invoice_statu}",String.valueOf(t.getInvoiceStatu()));
 		sql  = sql.replace("#{delivery_no}",String.valueOf(t.getDeliveryNo()));
 		sql  = sql.replace("#{valid_flag}",String.valueOf(t.getValidFlag()));
 		sql  = sql.replace("#{user_mobile}",String.valueOf(t.getUserMobile()));
 		sql  = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
 		sql  = sql.replace("#{create_person}",String.valueOf(t.getCreatePerson()));
 		sql  = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
 		sql  = sql.replace("#{update_person}",String.valueOf(t.getUpdatePerson()));
 		sql  = sql.replace("#{UUID}",UUID.randomUUID().toString());
 		return sql;
 	}
}